import { checkActor } from "../utils/mirUtil";
import { DamageChangeData } from "../全局对象/DamageManage";
import { getSkillId } from "../系统功能/GlobalObjectManage";
import { ActorNkeyEnum, BossSkillKey, CustomBuffId, DeBuffGroupId, IntervalBuffGroupId, MaxIntNum, StatusBuffGroupId } from "./基础配置";


//技能配置项
export const SpecialMonSkillSet = [
    {
        name: '宠物半兽人',
        //死亡触发
        TriggerDieEvent: true,
        //ai移动
        TriggerAINpcExecute: false,
        //释放技能触发
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: false,//是否启用自定义物品归属
        isHatred: false,//是否启用仇恨系统
        skillList: [
            // {
            //     CD:10000,
            //     skillId:42,
            // },
            // {
            //     CD:10000,
            //     skillId:37,
            // },
            {
                //为function 不设置则不检查条件
                condition: (Mon: TActor) => {
                    return true;
                },
                //Hp百分比大于等于这个值才能触发
                hplarge: 0,
                //Hp百分比小于等于这个值才能触发
                hpless: 0,
                CD: 2000,
                // skillId:33,
                skillName: "BOSS烈火"
            },


        ],
        // baseAbility: {
        //     ac1: 100,
        //     ac2: 100,
        //     mac1: 100,
        //     mac2: 100,
        //     dc1: 150,
        //     dc2: 150,
        // },
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        name: '精英祖玛教主',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        //被攻击触发 每个下属减免5%+5的伤害
        onStruct: (ActorObject: TActor, ADamageSource: TActor, Tag: number, SkillID: number, SkillLevel: number,
            Value: number): Array<DamageChangeData> => {
            let count = ADamageSource.SlaveCount;
            let damageChange: DamageChangeData = new DamageChangeData();
            damageChange.addPercent -= count * 65;
            damageChange.add -= count * 50;
            return [damageChange]
        },
        //攻击触发
        onAttack: (ActorObject: TActor, ADamageSource: TActor, Tag: number, SkillID:
            number, SkillLevel: number, Value: number): Array<DamageChangeData> => {
            return null
        },
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 1000,
            },
            {
                key: ActorNkeyEnum.DamageAddPer,
                value: 1000,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 1000,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 1000,
            },
        ],

        skillList: [
            // {
            //     CD:10000,
            //     skillName:'BOSS大招开启',
            //      //为function 不设置则不检查条件
            //      condition:(Mon: TActor)=>{
            //         return !Mon.GetCheck(BossSkillKey);
            //     },
            // },
            // {
            //     CD:8000,
            //     skillName:'BOSS大招',
            //      //为function 不设置则不检查条件
            //      condition:(Mon: TActor)=>{
            //         return Mon.GetCheck(BossSkillKey);
            //     },
            // },
            {
                CD: 6000,
                skillName: "BOSS召唤",
                //为function 不设置则不检查条件
                condition: (Mon: TActor) => {
                    return Mon.SlaveCount < 10;
                },
            },
            {
                CD: 10000,
                skillName: "BOSS吞噬",
                //为function 不设置则不检查条件
                condition: (Mon: TActor) => {
                    return Mon.SlaveCount > 2;
                },
            },
            {
                CD: 2000,
                skillName: "BOSS冰咆哮"
            },
        ]
    },

    {
        //怪物数据库的名称 哪些怪物使用此配置
        name: ['魔龙巨蛾', '铁翼巨蛾'],
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: false,//是否启用自定义物品归属
        isHatred: false,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 100,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 100,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 100,
            },
        ],

        skillList: [
            {
                CD: 1900,
                skillName: "BOSS雷电"
            },
        ]
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        name: ['魔龙战将', '圣殿护卫'],
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: false,//是否启用自定义物品归属
        isHatred: false,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 100,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 100,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 100,
            },
        ],

        skillList: [
            {
                CD: 4000,
                skillName: "BOSS烈火"
            },
        ]
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        name: ['魔龙力士', '火焰蛇王'],
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: false,//是否启用自定义物品归属
        isHatred: false,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 100,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 100,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 100,
            },
        ],

        skillList: [
            {
                CD: 10000,
                skillName: "BOSS旋风斩"
            },
        ]
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //算元素175
        name: '魔龙教主',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 250,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 250,
            },
        ],

        skillList: [
            {
                CD: 18000,
                skillName: "BOSS雷劫"
            },
            {
                CD: 6000,
                skillName: "BOSS灭天火"
            },
            {
                CD: 2000,
                skillName: "BOSS冰咆哮"
            },

        ],
        // baseAbility: {
        //     dc1: 180,
        //     dc2: 180,
        //     mc1: 180,
        //     mc2: 180,
        // },
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //没有召唤202 没算元素
        name: '米尔皇帝',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        //被攻击触发 每个下属减免5%+5的伤害
        onStruct: (ActorObject: TActor, ADamageSource: TActor, Tag: number, SkillID: number, SkillLevel: number,
            Value: number): Array<DamageChangeData> => {
            return null;
        },
        //攻击触发
        onAttack: (ActorObject: TActor, ADamageSource: TActor, Tag: number, SkillID:
            number, SkillLevel: number, Value: number): Array<DamageChangeData> => {
            let count = ADamageSource.SlaveCount;
            let damageChange: DamageChangeData = new DamageChangeData();
            damageChange.addPercent = count * 67;
            return [damageChange]
            // return null
        },
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 500,
            },
            {
                key: ActorNkeyEnum.MonDamageCut,
                value: 250,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 500,
            },
        ],
        // baseAbility: {
        //     dc1: 200,
        //     dc2: 200,
        //     mc1: 200,
        //     mc2: 200,
        // },

        skillList: [
            {
                CD: 6000,
                skillName: "BOSS召唤2",
                //为function 不设置则不检查条件
                condition: (Mon: TActor) => {
                    return Mon.SlaveCount <= 10;
                },
            },
            {
                CD: 15000,
                skillName: "BOSS死亡之眼"
            },
            {
                CD: 2000,
                skillName: "BOSS冰咆哮"
            },
        ],
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //没有召唤170
        name: '圣殿卫士',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 250,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 250,
            },
        ],
        // baseAbility: {
        //     dc1: 190,
        //     dc2: 190,
        //     mc1: 190,
        //     mc2: 190,
        // },

        skillList: [
            {
                CD: 20000,
                skillName: "BOSS冰霜群雨"
            },
            {
                CD: 10000,
                skillName: "BOSS雷劫"
            },
            {
                CD: 2000,
                skillName: "BOSS雷电"
            },
        ],

    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //理论0.8*200=160
        name: '雷炎蛛王',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 500,
            },
            {
                key: ActorNkeyEnum.MonDamageCut,
                value: 250,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 500,
            },
        ],
        // baseAbility: {
        //     dc1: 200,
        //     dc2: 200,
        //     mc1: 200,
        //     mc2: 200,
        // },

        skillList: [
            {
                CD: 60000,
                skillName: 'BOSS大招开启',
            },
            {
                CD: 10000,
                skillName: "BOSS雷劫"
            },
            {
                CD: 2000,
                skillName: "BOSS冰咆哮"
            },
        ],
        onRemoveBuff: (Actor: TActor, Buff: TBuff): void => {
            if (Buff.GetGroupID() != StatusBuffGroupId.stNone) {
                return
            }
            let list: TActorList = Actor.Map.GetActorListInRange(Actor.MapX, Actor.MapY, 8);
            let target: TActor = null
            for (let i = 0; i < list.Count; i++) {
                let item: TActor = list.Actor(i)

                if (checkActor(item) && !Actor.IsFrindlyTarget(item)) {

                    if (item.IsPlayer()) {
                        let play: TPlayObject = item as TPlayObject
                        if (play.GetObserverMode()) {
                            continue;
                        }

                    }
                    target = item
                    break;
                }
            }
            if (target) {
                let skillId = getSkillId("BOSS大招");
                Actor.MagicAttack(target, skillId, false);
            }
            list.Free()

        }
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //110
        name: '弓箭大师',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageCut,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageCut,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 500,
            },
        ],
        // addSkill: [
        //     {
        //         skillName: "魔法盾",
        //         level: 4,
        //     }
        // ],
        skillList: [
            {
                CD: 3000,
                skillName: '地狱塔开启',
            },
        ],
        // baseAbility: {
        //     dc1: 280,
        //     dc2: 280,
        //     mc1: 280,
        //     mc2: 280,
        // },
        onRemoveBuff: (Actor: TActor, Buff: TBuff): void => {
            if (Buff.GetGroupID() != IntervalBuffGroupId.biNone) {
                return
            }
            let mapx = Buff.Args1;
            let mapy = Buff.Args2;
            let list: TActorList = Actor.Map.GetActorListInRange(mapx, mapy, 1);
            GameLib.ShowEffect(Actor.Map.MapID, mapx, mapy, 109, 2);
            for (let i = 0; i < list.Count; i++) {
                let item: TActor = list.Actor(i)

                if (checkActor(item) && !Actor.IsFrindlyTarget(item)) {

                    if (item.IsPlayer()) {
                        let play: TPlayObject = item as TPlayObject
                        if (play.GetObserverMode()) {
                            continue;
                        }
                    }
                    let Args1 = 0
                    for (let j = 0; j < item.BuffCount; j++) {
                        let buff: TBuff = item.GetBuffByIndex(j);
                        if (buff.GetGroupID() == CustomBuffId.InfernoSkill) {

                            Args1 = buff.BuffValue
                            item.DeleteBuffByGroupID(CustomBuffId.InfernoSkill, CustomBuffId.InfernoSkill);
                            break;
                        }
                    }
                    Args1 += 1;

                    let damage: number = Math.floor(Args1 * (35 + item.MaxHP * 0.035))
                    item.SetNVar(ActorNkeyEnum.NoDamageCountTag, 1);
                    Actor.Damage(item, damage);

                    item.AddAbilityBuff(CustomBuffId.InfernoSkill, TBuffAbilityType.atNone, 6000, Args1, false);
                    item.DeleteBuffByGroupID(DeBuffGroupId.atMaxHP, DeBuffGroupId.atMaxHP)
                    item.AddAbilityBuff(DeBuffGroupId.atMaxHP, TBuffAbilityType.atMaxHP, 10000, -2000, true);

                }
            }


        },
        onFresh: (Envir: TEnvirnoment, Actor: TActor): void => {
        }
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //127
        name: '九尾魂石',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        addAbility: [
            {
                key: ActorNkeyEnum.DamageCut,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageCut,
                value: 200,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 500,
            },
        ],
        addSkill: [
            {
                skillName: "魔法盾",
                level: 4,
            }
        ],
        skillList: [
            {
                CD: 10000,
                skillName: '魔法盾开启',
            },
            {
                CD: 3000,
                skillName: "BOSS灭天火"
            },
        ],
        // baseAbility: {
        //     dc1: 260,
        //     dc2: 260,
        //     mc1: 260,
        //     mc2: 260,
        // },
        onFresh: (Envir: TEnvirnoment, Actor: TActor): void => {
            Actor.SetState(6, 60 * 60 * 24, 0)
        }
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //0.75*220=165
        name: '玉面素狐王',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        skillList: [
            {
                CD: 20000,
                skillName: "BOSS瞬移",
                condition: (Mon: TActor) => {
                    let list: TActorList = Mon.Map.GetActorListInRange(Mon.MapX, Mon.MapY, 2);
                    let num = 0;
                    for (let i = 0; i < list.Count; i++) {
                        let actor: TActor = list.Actor(i);
                        if (actor && !Mon.IsFriendlyTarget(actor)) {
                            num++;
                        }
                    }
                    list.Free();
                    return num > 2;
                },
            },
            {
                CD: 6000,
                skillName: "素狐群体"
            },
            {
                CD: 2000,
                skillName: "素狐单体"
            },
        ],
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 500,
            },
            {
                key: ActorNkeyEnum.MonDamageCut,
                value: 250,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 500,
            },
        ],
        // baseAbility: {
        //     dc1: 220,
        //     dc2: 220,
        //     mc1: 220,
        //     mc2: 220,
        // },
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //理论0.775*220=170.5
        name: '金爪赤狐王',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        skillList: [
            {
                //2
                CD: 20000,
                skillName: "BOSS超流星火雨",
            },
            {
                //1.5
                CD: 10000,
                skillName: "火狐群体"
            },
            {
                //1.5
                CD: 2000,
                skillName: "火狐单体"
            },
        ],
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 300,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 500,
            },
            {
                key: ActorNkeyEnum.MonDamageCut,
                value: 250,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 500,
            },
        ],
        // baseAbility: {
        //     dc1: 220,
        //     dc2: 220,
        //     mc1: 220,
        //     mc2: 220,
        // },
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        //0.75*250=188
        name: '狐月魔王',
        TriggerDieEvent: true,
        TriggerAINpcExecute: false,
        TriggerSelectMagicBeforeAttack: true,
        isExpHinter: true,//是否启用自定义物品归属
        isHatred: true,//是否启用仇恨系统
        //被攻击触发 每个下属减免5%+5的伤害
        onStruct: (ActorObject: TActor, ADamageSource: TActor, Tag: number, SkillID: number, SkillLevel: number,
            Value: number): Array<DamageChangeData> => {
            let count = ADamageSource.SlaveCount;
            let damageChange: DamageChangeData = new DamageChangeData();
            damageChange.addPercent -= count * 50;
            damageChange.add -= count * 50;
            return [damageChange]
        },
        addAbility: [
            {
                key: ActorNkeyEnum.DamageAdd,
                value: 400,
            },
            {
                key: ActorNkeyEnum.MonDamageAdd,
                value: 400,
            },
            {
                key: ActorNkeyEnum.MonDamageAddPer,
                value: 750,
            },
            {
                key: ActorNkeyEnum.MonDamageCut,
                value: 400,
            },
            {
                key: ActorNkeyEnum.MonDamageCutPer,
                value: 750,
            },
        ],
        onFresh: (Envir: TEnvirnoment, Actor: TActor): void => {
            Actor.SetState(6, 60 * 60 * 24, 0)
        },
        skillList: [
            {
                CD: 10000,
                skillName: "BOSS召唤",
                //为function 不设置则不检查条件
                condition: (Mon: TActor) => {
                    return Mon.SlaveCount < 10;
                },
            },
            {
                CD: 10000,
                skillName: "BOSS吞噬",
                //为function 不设置则不检查条件
                condition: (Mon: TActor) => {
                    return Mon.SlaveCount > 5;
                },
            },
            //1.5
            {
                CD: 20000,
                skillName: "BOSS冰霜群雨"
            },
            //1.5
            {
                CD: 2000,
                skillName: "BOSS冰咆哮"
            },
        ]
    },
    {
        //怪物数据库的名称 哪些怪物使用此配置
        name: '奴隶弓箭手1',
        baseAbility: {
            dc1: 1,
            d2: 1,
        },
        onFresh: (Envir: TEnvirnoment, Actor: TActor): void => {
        }
    }


]